package com.luge.lib_base.net

import androidx.lifecycle.MutableLiveData
import com.luge.lib_base.ktx.State
import com.luge.lib_base.ktx.StateType
import com.tencent.bugly.proguard.u
import retrofit2.HttpException
import java.net.ConnectException

object NetExeceptionHandle {
    fun handleException(e:Throwable?,
                        loadState: MutableLiveData<State>,
                        url:String = ""){

        e?.let {
            when(it) {
                is HttpException -> {
                    loadState.value = State(StateType.ERROR, url, message = it.message())
                }

                is ConnectException -> {
                    loadState.value = State(StateType.ERROR, url, message = "没有网络拉！！！")
                }
            }
        }

    }

}